package com.dianping.cat.home.exception.transform;

import com.dianping.cat.home.exception.entity.ExceptionExclude;
import com.dianping.cat.home.exception.entity.ExceptionLimit;
import com.dianping.cat.home.exception.entity.ExceptionRuleConfig;
import org.xml.sax.Attributes;







public class DefaultSaxMaker
  extends Object
  implements IMaker<Attributes>
{
  public ExceptionExclude buildExceptionExclude(Attributes attributes) {
/* 19 */     String id = attributes.getValue("id");
/* 20 */     String domain = attributes.getValue("domain");
/* 21 */     String name = attributes.getValue("name");
/* 22 */     ExceptionExclude exceptionExclude = new ExceptionExclude(id);

/* 24 */     if (domain != null) {
/* 25 */       exceptionExclude.setDomain(domain);
    }

/* 28 */     if (name != null) {
/* 29 */       exceptionExclude.setName(name);
    }

/* 32 */     return exceptionExclude;
  }


  public ExceptionLimit buildExceptionLimit(Attributes attributes) {
/* 37 */     String id = attributes.getValue("id");
/* 38 */     String domain = attributes.getValue("domain");
/* 39 */     String name = attributes.getValue("name");
/* 40 */     String warning = attributes.getValue("warning");
/* 41 */     String error = attributes.getValue("error");
/* 42 */     ExceptionLimit exceptionLimit = new ExceptionLimit(id);

/* 44 */     if (domain != null) {
/* 45 */       exceptionLimit.setDomain(domain);
    }

/* 48 */     if (name != null) {
/* 49 */       exceptionLimit.setName(name);
    }

/* 52 */     if (warning != null) {
/* 53 */       exceptionLimit.setWarning(((Integer)convert(Integer.class, warning, Integer.valueOf(0))).intValue());
    }

/* 56 */     if (error != null) {
/* 57 */       exceptionLimit.setError(((Integer)convert(Integer.class, error, Integer.valueOf(0))).intValue());
    }

/* 60 */     return exceptionLimit;
  }



/* 65 */   public ExceptionRuleConfig buildExceptionRuleConfig(Attributes attributes) { return new ExceptionRuleConfig(); }





  protected <T> T convert(Class<T> type, String value, T defaultValue) {
/* 72 */     if (value == null || value.length() == 0) {
/* 73 */       return defaultValue;
    }

/* 76 */     if (type == Boolean.class || type == boolean.class)
/* 77 */       return (T)Boolean.valueOf(value); 
/* 78 */     if (type == Integer.class || type == int.class)
/* 79 */       return (T)Integer.valueOf(value); 
/* 80 */     if (type == Long.class || type == long.class)
/* 81 */       return (T)Long.valueOf(value); 
/* 82 */     if (type == Short.class || type == short.class)
/* 83 */       return (T)Short.valueOf(value); 
/* 84 */     if (type == Float.class || type == float.class)
/* 85 */       return (T)Float.valueOf(value); 
/* 86 */     if (type == Double.class || type == double.class)
/* 87 */       return (T)Double.valueOf(value); 
/* 88 */     if (type == Byte.class || type == byte.class)
/* 89 */       return (T)Byte.valueOf(value); 
/* 90 */     if (type == Character.class || type == char.class) {
/* 91 */       return (T)Character.valueOf(value.charAt(0));
    }
/* 93 */     return (T)value;
  }
}


/* Location:              /Users/hanfei/Documents/apache-tomcat-9.0.24/webapps/cat/WEB-INF/classes/!/com/dianping/cat/home/exception/transform/DefaultSaxMaker.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       1.0.7
 */